/*
 * Copyright 2007 National Bioinformatics Network
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package dgbgui.gui;

import junit.framework.TestCase;


public class BoundingRectangleTest extends TestCase {
    
    protected void setUp() throws Exception {
        m_a = new BoundingRectangle(0,0,10,20);
        m_b = new BoundingRectangle(5,5,25,15);
        m_c = new BoundingRectangle(2,4,-10,-7);
        
    }
    
    protected void tearDown() throws Exception {
    }
    
    public void testNormalise() {
        BoundingRectangle a2 = new BoundingRectangle(0,20,10,-20);
        assertTrue(m_a.equals(a2));
        
        assertTrue(m_c.getX() == -8);
        assertTrue(m_c.getY() == -3);
        assertTrue(m_c.getWidth() == 10);
        assertTrue(m_c.getHeight() == 7);
    }
    
    public void testAdd()  {
        BoundingRectangle a1 = new BoundingRectangle(m_a);
        a1.add(m_b);
        assertTrue(a1.equals(new BoundingRectangle(0,0,30,20)));
        
        BoundingRectangle a2 = new BoundingRectangle(m_a);
        a2.add(m_c);
        assertTrue(a2.equals(new BoundingRectangle(-8,-3,18,23)));
        
        BoundingRectangle b = new BoundingRectangle(m_b);
        b.add(m_c);
        assertTrue(b.equals(new BoundingRectangle(-8,-3,38,23)));
        
        
    }
    
    private BoundingRectangle m_a,m_b,m_c;

}
